package controller

import (
	"workflow/controller/request"
	"workflow/service"

	"github.com/gin-gonic/gin"
)

func ListProjectsController(c *gin.Context) {
	projects, err := service.ListProjects()
	if err != nil {
		SendError(c, err)
	} else {
		SendData(c, projects)
	}
}

func CreateProjectController(c *gin.Context) {
	var req request.CreateProjectRequest
	var err error

	err = c.BindJSON(&req)
	if err != nil {
		SendError(c, err)
	}
	err = service.CreateProject(req.Name, req.Description)
	if err != nil {
		SendError(c, err)
	}
	SendData(c, nil)
}
